package com.zxr.diana.starter;

import com.zxr.diana.beans.BeanFactory;
import com.zxr.diana.core.ClassScanner;
import com.zxr.diana.web.handler.HandlerManager;
import com.zxr.diana.web.server.TomcatServer;
import java.util.List;

/**
 * @author xuerui.zhang
 * @since 2019-06-17 19:40
 */
public class MiniApplication {

    public static void run(Class<?> cls, String[] args) {
        System.out.println("Mini Spring Framework Starter");
        TomcatServer server = new TomcatServer(args);
        try {
            server.start();
            List<Class<?>> classList = ClassScanner.loadClasses(cls.getPackage().getName());
            HandlerManager.resolveMappingHandler(classList);
            BeanFactory.initBean(classList);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
